/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package supportlearning.entities;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 *
 * @author Huy
 */
@Entity
@Table(name = "CMSClass", catalog = "SupportLearningDB", schema = "dbo")
@NamedQueries({
    @NamedQuery(name = "CMSClass.findAll", query = "SELECT c FROM CMSClass c"),
    @NamedQuery(name = "CMSClass.findByClassId", query = "SELECT c FROM CMSClass c WHERE c.classId = :classId"),
    @NamedQuery(name = "CMSClass.findByClassName", query = "SELECT c FROM CMSClass c WHERE c.className = :className"),
    @NamedQuery(name = "CMSClass.findByDescription", query = "SELECT c FROM CMSClass c WHERE c.description = :description")})
public class CMSClass implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "ClassId", nullable = false)
    private Integer classId;
    @Basic(optional = false)
    @Column(name = "ClassName", nullable = false, length = 50)
    private String className;
    @Column(name = "Description", length = 100)
    private String description;
    @JoinColumn(name = "CourceId", referencedColumnName = "CourseId", nullable = false)
    @ManyToOne(optional = false, fetch = FetchType.EAGER)
    private Course course;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "cMSClass", fetch = FetchType.EAGER)
    private List<StudentProfile> studentProfileList;

    public CMSClass() {
    }

    public CMSClass(Integer classId) {
        this.classId = classId;
    }

    public CMSClass(Integer classId, String className) {
        this.classId = classId;
        this.className = className;
    }

    public Integer getClassId() {
        return classId;
    }

    public void setClassId(Integer classId) {
        this.classId = classId;
    }

    public String getClassName() {
        return className;
    }

    public void setClassName(String className) {
        this.className = className;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public Course getCourse() {
        return course;
    }

    public void setCourse(Course course) {
        this.course = course;
    }

    public List<StudentProfile> getStudentProfileList() {
        return studentProfileList;
    }

    public void setStudentProfileList(List<StudentProfile> studentProfileList) {
        this.studentProfileList = studentProfileList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (classId != null ? classId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof CMSClass)) {
            return false;
        }
        CMSClass other = (CMSClass) object;
        if ((this.classId == null && other.classId != null) || (this.classId != null && !this.classId.equals(other.classId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "supportlearning.entities.CMSClass[classId=" + classId + "]";
    }

}
